home *** CD-ROM | disk | FTP | other *** search
Text File | 1990-03-01 | 2.8 KB | 163 lines | [TEXT/KAHL] |
-
- DrawDefault( DPtr, def, boxes )
- DialogPtr DPtr;
- short def;
- short *boxes;
- {
- GrafPtr SavePort;
- Handle Hdl;
- short type;
- Rect rec;
- short i;
- short corner;
- short inset;
-
- GetPort(&SavePort);
- SetPort(DPtr);
- if(DPtr != FrontWindow()) ShowWindow(DPtr);
- if( def > 0 )
- {
- GetDItem( DPtr, def, &type, &Hdl, &rec );
- inset = -4.0*(short)((rec.right-rec.left)/60);
- corner = 16.0*(rec.bottom-rec.top)/20.0;
- InsetRect( &rec, inset, inset );
- PenSize( 3, 3 );
- FrameRoundRect( &rec, corner, corner );
- PenSize( 1, 1 );
- i = (*(DialogPeek)DPtr).editField+1;
- if( i > 2 )
- Select_text( DPtr, i );
- }
- i = 0;
- if( boxes != 0L )
- while( boxes[i] != 0 )
- FrameItem(DPtr, boxes[i++]);
- InitCursor();
-
- SetPort(SavePort);
- }
-
- FrameItem(DPtr, item)
- DialogPtr DPtr;
- short item;
- {
- Handle Hdl;
- short type;
- Rect rec;
-
- GetDItem(DPtr, item, &type, &Hdl, &rec);
- if( type == userItem )
- FrameRect(&rec);
- }
-
- ShorttoDialog( DPtr, item, value )
- DialogPtr DPtr;
- short item;
- short value;
- {
- char mystr1[256];
- Handle Hdl;
- short type;
- Rect rec;
-
- sprintf(mystr1, "%d", value);
- GetDItem(DPtr, item, &type, &Hdl, &rec);
- SetIText(Hdl, CtoPstr(mystr1));
- }
-
- DialogtoShort( DPtr, item, value, min, max )
- DialogPtr DPtr;
- short item;
- short *value;
- short min, max;
- {
- char mystr[256];
- Handle Hdl;
- short type;
- Rect rec;
- short i;
-
- for(i=0;i<=64;i++) mystr[i]=0;
- GetDItem(DPtr, item, &type, &Hdl, &rec);
- GetIText(Hdl, &mystr);
- mystr[0] = ' ';
- if(sscanf(mystr, "%d", &*value) == 0)
- {
- Select_text( DPtr, item );
- return(false);
- }
- if( (min != max) && (*value < min || *value > max) )
- {
- Select_text( DPtr, item );
- return(false);
- }
- return(true);
- }
-
- Do_radio_buttons( DPtr, num, items, hit )
- DialogPtr DPtr;
- short num;
- short *items;
- short hit;
- {
- Handle Hdl;
- short type;
- Rect rec;
- short i;
-
- for( i = 0; i < num; i++)
- Set_button( DPtr, items[i], 0 );
- Set_button( DPtr, hit, 1 );
- }
-
-
- Toggle_button( DPtr, item )
- DialogPtr DPtr;
- short item;
- {
- Handle Hdl;
- short type;
- Rect rec;
-
- if( If_button( DPtr, item ) )
- Set_button( DPtr, item, 0 );
- else
- Set_button( DPtr, item, 1 );
- }
-
- Set_button( DPtr, item, set )
- DialogPtr DPtr;
- short item;
- short set;
- {
- Handle Hdl;
- short type;
- Rect rec;
-
- GetDItem(DPtr, item, &type, &Hdl, &rec);
- SetCtlValue(Hdl, set);
- }
-
- Select_text( DPtr, item )
- DialogPtr DPtr;
- short item;
- {
- Handle Hdl;
- short type;
- Rect rec;
-
- GetDItem(DPtr, item, &type, &Hdl, &rec);
- SelIText( DPtr, item, 0, 255 );
- }
-
- If_button( DPtr, item )
- DialogPtr DPtr;
- short item;
- {
- Handle Hdl;
- short type;
- Rect rec;
-
- GetDItem(DPtr, item, &type, &Hdl, &rec);
- return( GetCtlValue(Hdl) == 1 );
- }